﻿// -----------------------------------------------------------------------
// <copyright file="DirectoryInfo.cs" company="Company">
// Company 2011
// </copyright>
// -----------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security;
using System.Security.AccessControl;
using Company.Common.Helper;
using Company.IO.Interfaces;
using FileAttributes = Company.IO.Interfaces.FileAttributes;
using SearchOption = Company.IO.Interfaces.SearchOption;

namespace Company.System.IO
{
    /// <summary>
    ///     Exposes instance methods for creating, moving, and enumerating through directories and subdirectories. This class
    ///     cannot be inherited.
    /// </summary>
    [Guid("41cc5f7d-9718-4439-9094-143d2d208d29")]
    [Serializable]
    public sealed class DirectoryInfo : IDirectoryInfo
    {
        #region Constructors

        /// <summary>
        ///     Initializes a new instance of the DirectoryInfo class on the specified System.IO.DirectoryInfo.
        /// </summary>
        /// <param name="directoryInfo">The System.IO.DirectoryInfo</param>
        public DirectoryInfo(global::System.IO.DirectoryInfo directoryInfo)
            : this(new SystemIoConverter(), directoryInfo)
        {
        }

        /// <summary>
        ///     Initializes a new instance of the DirectoryInfo class on the specified System.IO.DirectoryInfo and
        ///     ISystemIoConverter.
        /// </summary>
        /// <param name="systemIoConverter">The Converter to convert Types between Company and System.IO</param>
        /// <param name="directoryInfo">The System.IO.DirectoryInfo</param>
        public DirectoryInfo(ISystemIoConverter systemIoConverter, global::System.IO.DirectoryInfo directoryInfo)
        {
            CompanyContract.ThrowIfNull(systemIoConverter, "systemIoConverter");

            IoConverter = systemIoConverter;
            InternalDirectoryInfo = directoryInfo;
        }

        #endregion

        #region IDirectoryInfo Members

        /// <summary>
        ///     Gets the full path of the directory or file.
        /// </summary>
        /// <exception cref="IPathTooLongException">
        ///     <para>
        ///         The fully qualified path and file name is 260 or more characters.
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <value>
        ///     <para>
        ///         A string containing the full path.
        ///     </para>
        /// </value>
        public string FullName
        {
            get { return InternalDirectoryInfo.FullName; }
        }

        /// <summary>
        ///     Gets the string representing the extension part of the file.
        /// </summary>
        /// <value>
        ///     <para>
        ///         The Extension property returns the FileSystemInfo extension, including the period (.).
        ///         For example, for a file c:\NewFile.txt, this property returns ".txt".
        ///     </para>
        /// </value>
        public string Extension
        {
            get { return InternalDirectoryInfo.Extension; }
        }

        /// <summary>
        ///     For files, gets the name of the file.
        ///     For directories, gets the name of the last directory in the hierarchy if a hierarchy exists.
        ///     Otherwise, the Name property gets the name of the directory.
        /// </summary>
        /// <value>
        ///     <para>
        ///         A string that is the name of the parent directory,
        ///         the name of the last directory in the hierarchy,
        ///         or the name of a file, including the file name extension.
        ///     </para>
        /// </value>
        string IFileSystemInfo.Name
        {
            get { return InternalDirectoryInfo.Name; }
        }

        /// <summary>
        ///     Exposes instance methods for creating, moving, and enumerating through directories and subdirectories. This class
        ///     cannot be inherited.
        /// </summary>
        IDirectoryInfo IDirectoryInfo.Parent
        {
            get { return Convert(InternalDirectoryInfo.Parent); }
        }

        /// <summary>
        ///     Gets a value indicating whether the file or directory exists.
        /// </summary>
        /// <value>
        ///     <para>
        ///         true if the file or directory exists; otherwise, false.
        ///     </para>
        /// </value>
        bool IFileSystemInfo.Exists
        {
            get { return InternalDirectoryInfo.Exists; }
        }

        /// <summary>
        ///     Gets or sets the creation time of the current file or directory.
        /// </summary>
        /// <exception cref="PlatformNotSupportedException">
        ///     <para>
        ///         The current operating system is not Windows NT or later.
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The specified path is invalid; for example, it is on an unmapped drive.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         The caller attempts to set an invalid creation time.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         Refresh cannot initialize the data.
        ///     </para>
        /// </exception>
        /// <value>
        ///     <para>
        ///         The creation date and time of the current FileSystemInfo object.
        ///     </para>
        /// </value>
        public DateTime CreationTime
        {
            get { return InternalDirectoryInfo.CreationTime; }
            set { InternalDirectoryInfo.CreationTime = value; }
        }

        /// <summary>
        ///     Gets or sets the creation time, in coordinated universal time (UTC), of the current file or directory.
        /// </summary>
        /// <exception cref="PlatformNotSupportedException">
        ///     <para>
        ///         The current operating system is not Windows NT or later.
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The specified path is invalid; for example, it is on an unmapped drive.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         The caller attempts to set an invalid creation time.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         Refresh cannot initialize the data.
        ///     </para>
        /// </exception>
        /// <value>
        ///     <para>
        ///         The creation date and time in UTC format of the current FileSystemInfo object.
        ///     </para>
        /// </value>
        public DateTime CreationTimeUtc
        {
            get { return InternalDirectoryInfo.CreationTimeUtc; }
            set { InternalDirectoryInfo.CreationTimeUtc = value; }
        }

        /// <summary>
        ///     Gets or sets the time the current file or directory was last accessed.
        /// </summary>
        /// <exception cref="PlatformNotSupportedException">
        ///     <para>
        ///         The current operating system is not Windows NT or later.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         The caller attempts to set an invalid creation time.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         Refresh cannot initialize the data.
        ///     </para>
        /// </exception>
        /// <value>
        ///     <para>
        ///         The time that the current file or directory was last accessed.
        ///     </para>
        /// </value>
        public DateTime LastAccessTime
        {
            get { return InternalDirectoryInfo.LastAccessTime; }
            set { InternalDirectoryInfo.LastAccessTime = value; }
        }

        /// <summary>
        ///     Gets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed.
        /// </summary>
        /// <exception cref="PlatformNotSupportedException">
        ///     <para>
        ///         The current operating system is not Windows NT or later.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         The caller attempts to set an invalid creation time.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         Refresh cannot initialize the data.
        ///     </para>
        /// </exception>
        /// <value>
        ///     <para>
        ///         The UTC time that the current file or directory was last accessed.
        ///     </para>
        /// </value>
        public DateTime LastAccessTimeUtc
        {
            get { return InternalDirectoryInfo.LastAccessTimeUtc; }
            set { InternalDirectoryInfo.LastAccessTimeUtc = value; }
        }

        /// <summary>
        ///     Gets or sets the time when the current file or directory was last written to.
        /// </summary>
        /// <exception cref="PlatformNotSupportedException">
        ///     <para>
        ///         The current operating system is not Windows NT or later.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         The caller attempts to set an invalid creation time.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         Refresh cannot initialize the data.
        ///     </para>
        /// </exception>
        /// <value>
        ///     <para>
        ///         The time the current file was last written.
        ///     </para>
        /// </value>
        public DateTime LastWriteTime
        {
            get { return InternalDirectoryInfo.LastWriteTime; }
            set { InternalDirectoryInfo.LastWriteTime = value; }
        }

        /// <summary>
        ///     Gets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to.
        /// </summary>
        /// <exception cref="PlatformNotSupportedException">
        ///     <para>
        ///         The current operating system is not Windows NT or later.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         The caller attempts to set an invalid creation time.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         Refresh cannot initialize the data.
        ///     </para>
        /// </exception>
        /// <value>
        ///     <para>
        ///         The UTC time when the current file was last written to.
        ///     </para>
        /// </value>
        public DateTime LastWriteTimeUtc
        {
            get { return InternalDirectoryInfo.LastWriteTimeUtc; }
            set { InternalDirectoryInfo.LastWriteTimeUtc = value; }
        }

        /// <summary>
        ///     Gets or sets the attributes for the current file or directory.
        /// </summary>
        /// <exception cref="IFileNotFoundException">
        ///     <para>
        ///         The specified file does not exist.
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The specified path is invalid; for example, it is on an unmapped drive.
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         The caller attempts to set an invalid file attribute.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         Refresh cannot initialize the data.
        ///     </para>
        /// </exception>
        /// <value>
        ///     <para>
        ///         FileAttributes of the current FileSystemInfo.
        ///     </para>
        /// </value>
        public FileAttributes Attributes
        {
            get { return Convert(InternalDirectoryInfo.Attributes); }
            set { InternalDirectoryInfo.Attributes = Convert(value); }
        }

        /// <summary>
        ///     <para>
        ///         Gets the root portion of a path.
        ///     </para>
        /// </summary>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <return>
        ///     <para>
        ///         A DirectoryInfo object representing the root of a path.
        ///     </para>
        /// </return>
        IDirectoryInfo IDirectoryInfo.Root
        {
            get { return Convert(InternalDirectoryInfo.Root); }
        }

        /// <summary>
        ///     <para>
        ///         Creates a subdirectory or subdirectories on the specified path.
        ///         The specified path can be relative to this instance of the DirectoryInfo class.
        ///     </para>
        /// </summary>
        /// <param name="path">
        ///     <para>
        ///         The specified path. This cannot be a different disk volume or Universal Naming Convention (UNC) name.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         path does not specify a valid file path or contains invalid DirectoryInfo characters.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         path is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The specified path is invalid, such as being on an unmapped drive.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         The subdirectory cannot be created.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         A file or directory already has the name specified by path.
        ///     </para>
        /// </exception>
        /// <exception cref="IPathTooLongException">
        ///     <para>
        ///         The specified path, file name, or both exceed the system-defined maximum length.
        ///         For example, on Windows-based platforms, paths must be less than 248 characters,
        ///         and file names must be less than 260 characters.
        ///         The specified path, file name, or both are too long.
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have code access permission to create the directory.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         The caller does not have code access permission to read the directory
        ///         described by the returned DirectoryInfo object.
        ///         This can occur when the path parameter describes an existing directory.
        ///     </para>
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///     <para>
        ///         path contains a colon character (:) that is not part of a drive label ("C:\").
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         The last directory specified in path.
        ///     </para>
        /// </returns>
        IDirectoryInfo IDirectoryInfo.CreateSubdirectory(string path)
        {
            return Convert(InternalDirectoryInfo.CreateSubdirectory(path));
        }

        /// <summary>
        ///     <para>
        ///         Creates a subdirectory or subdirectories on the specified path with the specified security.
        ///         The specified path can be relative to this instance of the DirectoryInfo class.
        ///     </para>
        /// </summary>
        /// <param name="path">
        ///     <para>
        ///         The specified path. This cannot be a different disk volume or Universal Naming Convention (UNC) name.
        ///     </para>
        /// </param>
        /// <param name="directorySecurity">
        ///     <para>
        ///         The security to apply.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         path does not specify a valid file path or contains invalid DirectoryInfo characters.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         path is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The specified path is invalid, such as being on an unmapped drive.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         The subdirectory cannot be created.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         A file or directory already has the name specified by path.
        ///     </para>
        /// </exception>
        /// <exception cref="IPathTooLongException">
        ///     <para>
        ///         The specified path, file name, or both exceed the system-defined maximum length.
        ///         For example, on Windows-based platforms, paths must be less than 248 characters,
        ///         and file names must be less than 260 characters.
        ///         The specified path, file name, or both are too long.
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have code access permission to create the directory.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         The caller does not have code access permission to read the directory
        ///         described by the returned DirectoryInfo object.
        ///         This can occur when the path parameter describes an existing directory.
        ///     </para>
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///     <para>
        ///         path contains a colon character (:) that is not part of a drive label ("C:\").
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         The last directory specified in path.
        ///     </para>
        /// </returns>
        IDirectoryInfo IDirectoryInfo.CreateSubdirectory(string path, DirectorySecurity directorySecurity)
        {
            return Convert(InternalDirectoryInfo.CreateSubdirectory(path, directorySecurity));
        }

        /// <summary>
        ///     <para>
        ///         Creates a directory.
        ///     </para>
        /// </summary>
        /// <exception cref="IIOException">
        ///     <para>
        ///         The directory cannot be created.
        ///     </para>
        /// </exception>
        void IDirectoryInfo.Create()
        {
            InternalDirectoryInfo.Create();
        }

        /// <summary>
        ///     <para>
        ///         Creates a directory using a DirectorySecurity object.
        ///     </para>
        /// </summary>
        /// <param name="directorySecurity">
        ///     <para>
        ///         The access control to apply to the directory.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         path is a zero-length string, contains only white space, or contains one or more invalid characters as defined
        ///         by InvalidPathChars.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         path is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The specified path is invalid, such as being on an unmapped drive.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         The directory specified by path is read-only or is not empty.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         The directory specified by path is read-only or is not empty.
        ///     </para>
        /// </exception>
        /// <exception cref="IPathTooLongException">
        ///     <para>
        ///         The specified path, file name, or both exceed the system-defined maximum length.
        ///         For example, on Windows-based platforms, paths must be less than 248 characters,
        ///         and file names must be less than 260 characters.
        ///         The specified path, file name, or both are too long.
        ///     </para>
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///     <para>
        ///         path contains a colon character (:) that is not part of a drive label ("C:\").
        ///     </para>
        /// </exception>
        void IDirectoryInfo.Create(DirectorySecurity directorySecurity)
        {
            InternalDirectoryInfo.Create(directorySecurity);
        }

        /// <summary>
        ///     <para>
        ///         Gets a DirectorySecurity object that encapsulates the access control list
        ///         (ACL) entries for the directory described by the current DirectoryInfo object.
        ///     </para>
        /// </summary>
        /// <exception cref="SystemException">
        ///     <para>
        ///         The directory coSystem.SystemExceptionld not be found or modified.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         An I/O error occurred while opening the directory.
        ///     </para>
        /// </exception>
        /// <exception cref="PlatformNotSupportedException">
        ///     <para>
        ///         The specified path, file name, or both exceed the system-defined maximum length.
        ///         For example, on Windows-based platforms, paths must be less than 248 characters,
        ///         and file names must be less than 260 characters.
        ///         The specified path, file name, or both are too long.
        ///     </para>
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">
        ///     <para>
        ///         The current process does not have access to open the directory.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         The directory is read-only.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         This operation is not supported on the current platform.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///     <para>
        ///         path contains a colon character (:) that is not part of a drive label ("C:\").
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         A DirectorySecurity object that encapsulates the access control rules for the directory.
        ///     </para>
        /// </returns>
        DirectorySecurity IDirectoryInfo.GetAccessControl()
        {
            return InternalDirectoryInfo.GetAccessControl();
        }

        /// <summary>
        ///     <para>
        ///         Gets a DirectorySecurity object that encapsulates the access control list
        ///         (ACL) entries for the directory described by the current DirectoryInfo object.
        ///     </para>
        /// </summary>
        /// <param name="includeSections">
        ///     <para>
        ///         One of the AccessControlSections values that specifies the type of access control list (ACL) information to
        ///         receive.
        ///     </para>
        /// </param>
        /// <exception cref="SystemException">
        ///     <para>
        ///         The directory could not be found or modified.
        ///     </para>
        /// </exception>
        /// <exception cref="IIOException">
        ///     <para>
        ///         An I/O error occurred while opening the directory.
        ///     </para>
        /// </exception>
        /// <exception cref="PlatformNotSupportedException">
        ///     <para>
        ///         The specified path, file name, or both exceed the system-defined maximum length.
        ///         For example, on Windows-based platforms, paths must be less than 248 characters,
        ///         and file names must be less than 260 characters.
        ///         The specified path, file name, or both are too long.
        ///     </para>
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">
        ///     <para>
        ///         The current process does not have access to open the directory.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         The directory is read-only.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         This operation is not supported on the current platform.
        ///     </para>
        ///     <para>
        ///         - or -
        ///     </para>
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <exception cref="NotSupportedException">
        ///     <para>
        ///         path contains a colon character (:) that is not part of a drive label ("C:\").
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         A DirectorySecurity object that encapsulates the access control rules for the directory.
        ///     </para>
        /// </returns>
        DirectorySecurity IDirectoryInfo.GetAccessControl(AccessControlSections includeSections)
        {
            return InternalDirectoryInfo.GetAccessControl(includeSections);
        }

        /// <summary>
        ///     <para>
        ///         Applies access control list (ACL) entries described by a DirectorySecurity
        ///         object to the directory described by the current DirectoryInfo object.
        ///     </para>
        /// </summary>
        /// <param name="directorySecurity">
        ///     <para>
        ///         An object that describes an ACL entry to apply to the directory described by the path parameter
        ///     </para>
        /// </param>
        /// <exception cref="SystemException">
        ///     <para>
        ///         The file could not be found or modified.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         The directorySecurity parameter is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="PlatformNotSupportedException">
        ///     <para>
        ///         The current operating system is not Microsoft Windows 2000 or later.
        ///     </para>
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">
        ///     <para>
        ///         The current process does not have access to open the file.
        ///     </para>
        /// </exception>
        void IDirectoryInfo.SetAccessControl(DirectorySecurity directorySecurity)
        {
            InternalDirectoryInfo.SetAccessControl(directorySecurity);
        }

        /// <summary>
        ///     <para>
        ///         Returns a file list from the current directory.
        ///     </para>
        /// </summary>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path is invalid, such as being on an unmapped drive.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An array of type FileInfo.
        ///     </para>
        /// </returns>
        IFileInfo[] IDirectoryInfo.GetFiles()
        {
            return Convert(InternalDirectoryInfo.GetFiles());
        }

        /// <summary>
        ///     <para>
        ///         Returns a file list from the current directory matching the given search pattern.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string, such as "*.txt".
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         searchPattern contains one or more invalid characters defined by the GetInvalidPathChars method.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path is invalid (for example, it is on an unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An array of type FileInfo.
        ///     </para>
        /// </returns>
        IFileInfo[] IDirectoryInfo.GetFiles(string searchPattern)
        {
            return Convert(InternalDirectoryInfo.GetFiles(searchPattern));
        }

        /// <summary>
        ///     <para>
        ///         Returns a file list from the current directory matching the given search pattern.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. For example, "System*" can be used to search for all directories that begin with the word
        ///         "System".
        ///     </para>
        /// </param>
        /// <param name="searchOption">
        ///     <para>
        ///         One of the enumeration values that specifies whether the search operation should include only the current
        ///         directory or all subdirectories.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         searchPattern contains one or more invalid characters defined by the GetInvalidPathChars method.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         searchOption is not a valid SearchOption value.
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path is invalid (for example, it is on an unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An array of type FileInfo.
        ///     </para>
        /// </returns>
        IFileInfo[] IDirectoryInfo.GetFiles(string searchPattern, SearchOption searchOption)
        {
            return Convert(InternalDirectoryInfo.GetFiles(searchPattern, Convert(searchOption)));
        }

        /// <summary>
        ///     <para>
        ///         Returns the subdirectories of the current directory.
        ///     </para>
        /// </summary>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the DirectoryInfo object is invalid, such as being on an unmapped drive.
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An array of DirectoryInfo objects.
        ///     </para>
        /// </returns>
        IDirectoryInfo[] IDirectoryInfo.GetDirectories()
        {
            return Convert(InternalDirectoryInfo.GetDirectories());
        }

        /// <summary>
        ///     <para>
        ///         Returns an array of directories in the current DirectoryInfo matching the given search criteria.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. For example, "System*" can be used to search for all directories that begin with the word
        ///         "System".
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         searchPattern contains one or more invalid characters defined by the GetInvalidPathChars method.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path is invalid (for example, it is on an unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An array of type DirectoryInfo matching searchPattern.
        ///     </para>
        /// </returns>
        IDirectoryInfo[] IDirectoryInfo.GetDirectories(string searchPattern)
        {
            return Convert(InternalDirectoryInfo.GetDirectories(searchPattern));
        }

        /// <summary>
        ///     <para>
        ///         Returns an array of directories in the current DirectoryInfo matching
        ///         the given search criteria and using a value to determine whether to search subdirectories.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. For example, "System*" can be used to search for all directories that begin with the word
        ///         "System".
        ///     </para>
        /// </param>
        /// <param name="searchOption">
        ///     <para>
        ///         One of the enumeration values that specifies whether the search operation should include only the current
        ///         directory or all subdirectories.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         searchPattern contains one or more invalid characters defined by the GetInvalidPathChars method.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         searchOption is not a valid SearchOption value.
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path is invalid (for example, it is on an unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="UnauthorizedAccessException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An array of type <see cref="DirectoryInfo" /> matching searchPattern.
        ///     </para>
        /// </returns>
        IDirectoryInfo[] IDirectoryInfo.GetDirectories(string searchPattern, SearchOption searchOption)
        {
            return Convert(InternalDirectoryInfo.GetDirectories(searchPattern, Convert(searchOption)));
        }

        /// <summary>
        ///     <para>
        ///         Returns an array of strongly typed <see cref="IFileSystemInfo" /> entries representing all the files and
        ///         subdirectories in a directory.
        ///     </para>
        /// </summary>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the DirectoryInfo object is invalid, such as being on an unmapped drive.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An array of strongly typed <see cref="IFileSystemInfo" /> entries.
        ///     </para>
        /// </returns>
        IFileSystemInfo[] IDirectoryInfo.GetFileSystemInfos()
        {
            return Convert(InternalDirectoryInfo.GetFileSystemInfos());
        }

        /// <summary>
        ///     <para>
        ///         Retrieves an array of strongly typed <see cref="IFileSystemInfo" /> objects representing
        ///         the files and subdirectories that match the specified search criteria.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. For example, "System*" can be used to search for all directories that begin with the word
        ///         "System".
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         searchPattern contains one or more invalid characters defined by the GetInvalidPathChars method.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path is invalid (for example, it is on an unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An array of strongly typed <see cref="IFileSystemInfo" /> objects matching the search criteria
        ///     </para>
        /// </returns>
        IFileSystemInfo[] IDirectoryInfo.GetFileSystemInfos(string searchPattern)
        {
            return Convert(InternalDirectoryInfo.GetFileSystemInfos(searchPattern));
        }

        /// <summary>
        ///     <para>
        ///         Retrieves an array of <see cref="IFileSystemInfo" /> objects that represent the files and subdirectories
        ///         matching the specified search criteria.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. The default pattern is "*", which returns all files and directories.
        ///     </para>
        /// </param>
        /// <param name="searchOption">
        ///     <para>
        ///         One of the enumeration values that specifies whether the search operation should include only the current
        ///         directory or all subdirectories.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentException">
        ///     <para>
        ///         searchPattern contains one or more invalid characters defined by the GetInvalidPathChars method.
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         searchOption is not a valid SearchOption value.
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path is invalid (for example, it is on an unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An array of file system entries that match the search criteria.
        ///     </para>
        /// </returns>
        IFileSystemInfo[] IDirectoryInfo.GetFileSystemInfos(string searchPattern, SearchOption searchOption)
        {
            return Convert(InternalDirectoryInfo.GetFileSystemInfos(searchPattern, Convert(searchOption)));
        }

        /// <summary>
        ///     <para>
        ///         Returns an enumerable collection of file information in the current directory.
        ///     </para>
        /// </summary>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the <see cref="IFileInfo" /> object is invalid (for example, it is on an unmapped
        ///         drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An enumerable collection of the files in the current directory.
        ///     </para>
        /// </returns>
        IEnumerable<IFileInfo> IDirectoryInfo.EnumerateFiles()
        {
            return Convert(InternalDirectoryInfo.EnumerateFiles());
        }

        /// <summary>
        ///     <para>
        ///         Returns an enumerable collection of file information that matches a search pattern.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. The default pattern is "*", which returns all files.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the FileInfo object is invalid, (for example, it is on an unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An enumerable collection of files that matches searchPattern.
        ///     </para>
        /// </returns>
        IEnumerable<IFileInfo> IDirectoryInfo.EnumerateFiles(string searchPattern)
        {
            return Convert(InternalDirectoryInfo.EnumerateFiles(searchPattern));
        }

        /// <summary>
        ///     <para>
        ///         Returns an enumerable collection of file information that matches a specified search pattern and search
        ///         subdirectory option.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. The default pattern is "*", which returns all files.
        ///     </para>
        /// </param>
        /// <param name="searchOption">
        ///     <para>
        ///         One of the enumeration values that specifies whether the search operation should include only the current
        ///         directory or all subdirectories. The default value is TopDirectoryOnly.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         searchOption is not a valid SearchOption value.
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the FileInfo object is invalid (for example, it is on an unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An enumerable collection of files that matches searchPattern and searchOption.
        ///     </para>
        /// </returns>
        IEnumerable<IFileInfo> IDirectoryInfo.EnumerateFiles(string searchPattern, SearchOption searchOption)
        {
            return Convert(InternalDirectoryInfo.EnumerateFiles(searchPattern, Convert(searchOption)));
        }

        /// <summary>
        ///     <para>
        ///         Returns an enumerable collection of directory information in the current directory.
        ///     </para>
        /// </summary>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the <see cref="IDirectoryInfo" /> object is invalid (for example, it is on an unmapped
        ///         drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An enumerable collection of directories in the current directory.
        ///     </para>
        /// </returns>
        IEnumerable<IDirectoryInfo> IDirectoryInfo.EnumerateDirectories()
        {
            return Convert(InternalDirectoryInfo.EnumerateDirectories());
        }

        /// <summary>
        ///     <para>
        ///         Returns an enumerable collection of directory information that matches a specified search pattern.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. The default pattern is "*", which returns all files.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the DirectoryInfo object is invalid, (for example, it is on an unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An enumerable collection of directories that matches searchPattern.
        ///     </para>
        /// </returns>
        IEnumerable<IDirectoryInfo> IDirectoryInfo.EnumerateDirectories(string searchPattern)
        {
            return Convert(InternalDirectoryInfo.EnumerateDirectories(searchPattern));
        }

        /// <summary>
        ///     <para>
        ///         Returns an enumerable collection of directory information that matches a specified search pattern and search
        ///         subdirectory option.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. The default pattern is "*", which returns all files.
        ///     </para>
        /// </param>
        /// <param name="searchOption">
        ///     <para>
        ///         One of the enumeration values that specifies whether the search operation should include only the current
        ///         directory or all subdirectories. The default value is TopDirectoryOnly.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         searchOption is not a valid SearchOption value.
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the DirectoryInfo object is invalid (for example, it is on an unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An enumerable collection of directories that matches searchPattern and searchOption.
        ///     </para>
        /// </returns>
        IEnumerable<IDirectoryInfo> IDirectoryInfo.EnumerateDirectories(string searchPattern, SearchOption searchOption)
        {
            return Convert(InternalDirectoryInfo.EnumerateDirectories(searchPattern, Convert(searchOption)));
        }

        /// <summary>
        ///     <para>
        ///         Returns an enumerable collection of file system information in the current directory.
        ///     </para>
        /// </summary>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the <see cref="IFileSystemInfo" /> object is invalid (for example, it is on an
        ///         unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An enumerable collection of file system information in the current directory.
        ///     </para>
        /// </returns>
        IEnumerable<IFileSystemInfo> IDirectoryInfo.EnumerateFileSystemInfos()
        {
            return Convert(InternalDirectoryInfo.EnumerateFileSystemInfos());
        }

        /// <summary>
        ///     <para>
        ///         Returns an enumerable collection of file system information that matches a specified search pattern.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. The default pattern is "*", which returns all files.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the <see cref="IFileSystemInfo" /> object is invalid (for example, it is on an
        ///         unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An enumerable collection of file system information objects that matches searchPattern.
        ///     </para>
        /// </returns>
        IEnumerable<IFileSystemInfo> IDirectoryInfo.EnumerateFileSystemInfos(string searchPattern)
        {
            return Convert(InternalDirectoryInfo.EnumerateFileSystemInfos(searchPattern));
        }

        /// <summary>
        ///     <para>
        ///         Returns an enumerable collection of file system information that matches a specified search pattern and search
        ///         subdirectory option.
        ///     </para>
        /// </summary>
        /// <param name="searchPattern">
        ///     <para>
        ///         The search string. The default pattern is "*", which returns all files.
        ///     </para>
        /// </param>
        /// <param name="searchOption">
        ///     <para>
        ///         One of the enumeration values that specifies whether the search operation
        ///         should include only the current directory or all subdirectories.
        ///         The default value is TopDirectoryOnly.
        ///     </para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <para>
        ///         searchPattern is a null reference (Nothing in Visual Basic).
        ///     </para>
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">
        ///     <para>
        ///         searchOption is not a valid SearchOption value.
        ///     </para>
        /// </exception>
        /// <exception cref="IDirectoryNotFoundException">
        ///     <para>
        ///         The path encapsulated in the <see cref="IFileSystemInfo" /> object is invalid (for example, it is on an
        ///         unmapped drive).
        ///     </para>
        /// </exception>
        /// <exception cref="SecurityException">
        ///     <para>
        ///         The caller does not have the required permission.
        ///     </para>
        /// </exception>
        /// <returns>
        ///     <para>
        ///         An enumerable collection of file system information objects that matches searchPattern and searchOption.
        ///     </para>
        /// </returns>
        IEnumerable<IFileSystemInfo> IDirectoryInfo.EnumerateFileSystemInfos(string searchPattern,
            SearchOption searchOption)
        {
            return Convert(InternalDirectoryInfo.EnumerateFileSystemInfos(searchPattern, Convert(searchOption)));
        }

        /// <summary>
        ///     Moves a DirectoryInfo instance and its contents to a new path.
        /// </summary>
        /// <param name="destDirName">
        ///     The name and path to which to move this directory.
        ///     The destination cannot be another disk volume or a directory with the identical name.
        ///     It can be an existing directory to which you want to add this directory as a subdirectory.
        /// </param>
        void IDirectoryInfo.MoveTo(string destDirName)
        {
            InternalDirectoryInfo.MoveTo(destDirName);
        }

        /// <summary>
        ///     Deletes a file or directory.
        /// </summary>
        /// <exception cref="IDirectoryNotFoundException">
        ///     The specified path is invalid; for example, it is on an unmapped drive.
        /// </exception>
        /// <exception cref="IIOException">
        ///     There is an open handle on the file or directory, and the operating system is Windows XP or earlier.
        ///     This open handle can result from enumerating directories and files.
        ///     For more information, see How to: Enumerate Directories and Files.
        /// </exception>
        void IFileSystemInfo.Delete()
        {
            InternalDirectoryInfo.Delete();
        }

        /// <summary>
        ///     Refreshes the state of the object.
        /// </summary>
        /// <exception cref="IIOException">
        ///     <para>
        ///         A device such as a disk drive is not ready.
        ///     </para>
        /// </exception>
        public void Refresh()
        {
            InternalDirectoryInfo.Refresh();
        }

        /// <summary>
        ///     Deletes a file or directory.
        /// </summary>
        /// <param name="recursive">recursive cal</param>
        /// <exception cref="IDirectoryNotFoundException">
        ///     The specified path is invalid; for example, it is on an unmapped drive.
        /// </exception>
        /// <exception cref="IIOException">
        ///     There is an open handle on the file or directory, and the operating system is Windows XP or earlier.
        ///     This open handle can result from enumerating directories and files.
        ///     For more information, see How to: Enumerate Directories and Files.
        /// </exception>
        void IDirectoryInfo.Delete(bool recursive)
        {
            InternalDirectoryInfo.Delete(recursive);
        }

        /// <summary>
        ///     Returns a <see cref="string" /> that represents this instance.
        /// </summary>
        /// <returns>
        ///     A <see cref="string" /> that represents this instance.
        /// </returns>
        string IDirectoryInfo.ToString()
        {
            return InternalDirectoryInfo.ToString();
        }

        /// <summary>
        ///     Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo" /> with the data needed to serialize the
        ///     target object.
        /// </summary>
        /// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo" /> to populate with data.</param>
        /// <param name="context">
        ///     The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext" />) for this
        ///     serialization.
        /// </param>
        /// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            InternalDirectoryInfo.GetObjectData(info, context);
        }

        #endregion

        #region Private Member

        /// <summary>
        ///     Gets or set the intenal DirectoryInfo object
        /// </summary>
        private global::System.IO.DirectoryInfo InternalDirectoryInfo { get; set; }

        /// <summary>
        ///     Gets or sets the converter
        /// </summary>
        private ISystemIoConverter IoConverter { get; set; }

        #endregion

        /// <summary>
        ///     Determines whether the specified <see cref="object" /> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="object" /> to compare with this instance.</param>
        /// <returns>
        ///     <c>true</c> if the specified <see cref="object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return false;
            }

            // If parameter cannot be cast to Point return false.
            var p = obj as IDirectoryInfo;
            if (p == null)
            {
                return false;
            }

            var current = this as IDirectoryInfo;

            // Return true if the fields match:
            return (current.Extension == p.Extension) && (current.FullName == p.FullName) && (current.Name == p.Name);
        }

        /// <summary>
        ///     Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        ///     A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
        /// </returns>
        public override int GetHashCode()
        {
            return FullName.GetHashCode()*Extension.GetHashCode();
        }

        #region Private Helper

        /// <summary>
        ///     Converts the specified directory info.
        /// </summary>
        /// <param name="directoryInfo">The directory info.</param>
        /// <returns>the convertet object</returns>
        private IDirectoryInfo Convert(global::System.IO.DirectoryInfo directoryInfo)
        {
            return IoConverter.Convert(directoryInfo);
        }

        /// <summary>
        ///     Converts the specified directory infos.
        /// </summary>
        /// <param name="directoryInfos">The directory infos.</param>
        /// <returns>the convertet object</returns>
        private IDirectoryInfo[] Convert(global::System.IO.DirectoryInfo[] directoryInfos)
        {
            return IoConverter.Convert(directoryInfos);
        }

        /// <summary>
        ///     Converts the specified directory infos.
        /// </summary>
        /// <param name="directoryInfos">The directory infos.</param>
        /// <returns>the convertet object</returns>
        private IEnumerable<IDirectoryInfo> Convert(IEnumerable<global::System.IO.DirectoryInfo> directoryInfos)
        {
            return IoConverter.Convert(directoryInfos);
        }

        /// <summary>
        ///     Converts the specified file infos.
        /// </summary>
        /// <param name="fileInfos">The file infos.</param>
        /// <returns>the convertet object</returns>
        private IFileInfo[] Convert(global::System.IO.FileInfo[] fileInfos)
        {
            return IoConverter.Convert(fileInfos);
        }

        /// <summary>
        ///     Converts the specified i enumerable.
        /// </summary>
        /// <param name="enumerable">The i enumerable.</param>
        /// <returns>the convertet object</returns>
        private IEnumerable<IFileInfo> Convert(IEnumerable<global::System.IO.FileInfo> enumerable)
        {
            return IoConverter.Convert(enumerable);
        }

        /// <summary>
        ///     Converts the specified file system infos.
        /// </summary>
        /// <param name="fileSystemInfos">The file system infos.</param>
        /// <returns>the convertet object</returns>
        private IFileSystemInfo[] Convert(FileSystemInfo[] fileSystemInfos)
        {
            return IoConverter.Convert(fileSystemInfos);
        }

        /// <summary>
        ///     Converts the specified i enumerable.
        /// </summary>
        /// <param name="enumerable">The i enumerable.</param>
        /// <returns>the convertet object</returns>
        private IEnumerable<IFileSystemInfo> Convert(IEnumerable<FileSystemInfo> enumerable)
        {
            return IoConverter.Convert(enumerable);
        }

        /// <summary>
        ///     Converts the specified search option.
        /// </summary>
        /// <param name="searchOption">The search option.</param>
        /// <returns>the convertet object</returns>
        private global::System.IO.SearchOption Convert(SearchOption searchOption)
        {
            return IoConverter.Convert(searchOption);
        }

        /// <summary>
        ///     Converts the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <returns>the convertet object</returns>
        private global::System.IO.FileAttributes Convert(FileAttributes value)
        {
            return IoConverter.Convert(value);
        }

        /// <summary>
        ///     Converts the specified file attributes.
        /// </summary>
        /// <param name="fileAttributes">The file attributes.</param>
        /// <returns>the convertet object</returns>
        private FileAttributes Convert(global::System.IO.FileAttributes fileAttributes)
        {
            return IoConverter.Convert(fileAttributes);
        }

        #endregion
    }
}